<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>products</title>
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js">
</script>
 
</head>
<body>

</body>
<script type="text/javascript">
$(document).ready( function () {
   $.ajax({
	   url:'/product/product/findAll',
	   type:'get',
	   success: function(msg){
		   
		   var html="";
		   html+= ("<table>");
		   html+= ("<tr>");
		    html+= ("<td>");
		    html+= ("ID");
		    html+= ("</td>");
		    html+= ("<td>");
		    html+= ("商品");
		    html+= ("</td>");
		    html+= ("<td>");
		    html+= ("价格");
		    html+= ("</td>");
		    html+= ("<td>");
		    html+= ("库存");
		    html+= ("</td>");
		    html+= ("<td>");
		    html+= ("描述");
		    html+= ("</td>");
		    html+= ("<td>");
		    html+= ("操作");
		    html+= ("</td>");
		    html+= ("</tr>");
		   $(msg).each(function(i,e){
	    	 html+= ("<tr>");
	    	 html+= ("<td>");
	    	 html+= (e.id);
	    	 html+= ("</td>");
	    	 html+= ("<td>");
	    	 html+= (e.name);
	    	 html+= ("</td>");
	    	 html+= ("</td>");
	    	 html+= ("<td>");
	    	 html+= (e.price);
	    	 html+= ("</td>");
	    	 html+= ("<td>");
	    	 html+= (e.count);
	    	 html+= ("</td>");
	    	 html+= ("<td>");
	    	 html+= (e.desc);
	    	 html+= ("</td>");
	    	 html+= ("<td>");
	    	 html+= ("<input type='button' value='下单1个' onclick=orderIt('"+e.id+"')>");
	    	 html+= ("</td>");
	    	 html+= ("</tr>");
		   });
		    html+= ("</table>");
		    $('body').html(html);
	   }
	   
   });
} );
function orderIt(id){
	$.ajax({
		url:'/order/order/createOrder',
		type:'post',
		dataType:'json',
		data:{productId:id,nums:1,userId:1},
		success:function(data){
			alert(data);
		}
	});
}
</script>
</html>